//本插件由www.swiper.com.cn提供
let swiperAnimateAction = {
  swiperAnimateCache(a) {
    for (
      let allBoxes = a.$el[0].querySelectorAll(".ani"), i = 0;
      i < allBoxes.length;
      i++
    )
      allBoxes[i].attributes["style"]
        ? allBoxes[i].setAttribute(
            "swiper-animate-style-cache",
            allBoxes[i].attributes["style"].value
          )
        : allBoxes[i].setAttribute("swiper-animate-style-cache", " "),
        (allBoxes[i].style.visibility = "hidden");
  },
  swiperAnimate(a) {
    let b = [];
    try {
      b = a.slides[a.activeIndex].querySelectorAll(".ani");
    } catch (e) {
      if (a.$el.length > 0) {
        b = a.$el[0]
          .querySelectorAll(".swiper-slide")
          [a.activeIndex].querySelectorAll(".ani");
      }
    }
    for (let i = 0; i < b.length; i++) {
      let effect, style, duration, delay;
      (b[i].style.visibility = "visible"),
        (effect = b[i].attributes["swiper-animate-effect"]
          ? b[i].attributes["swiper-animate-effect"].value
          : ""),
        (b[i].className = b[i].className + "  " + effect + " " + "animated"),
        (style = b[i].attributes["style"].value),
        (duration = b[i].attributes["swiper-animate-duration"]
          ? b[i].attributes["swiper-animate-duration"].value
          : ""),
        duration &&
          (style =
            style +
            "animation-duration:" +
            duration +
            ";-webkit-animation-duration:" +
            duration +
            ";"),
        (delay = b[i].attributes["swiper-animate-delay"]
          ? b[i].attributes["swiper-animate-delay"].value
          : ""),
        delay &&
          (style =
            style +
            "animation-delay:" +
            delay +
            ";-webkit-animation-delay:" +
            delay +
            ";"),
        b[i].setAttribute("style", style);
    }
    //swiperAnimateAction.clearSwiperAnimate();
  },
  clearSwiperAnimate(a) {
    for (let k = 0; k < a.slides.length; k++) {
      if (k != a.activeIndex) {
        for (
          let curBoxes = a.slides[k].querySelectorAll(".ani"), i = 0;
          i < curBoxes.length;
          i++
        ) {
          let effect;
          curBoxes[i].attributes["swiper-animate-style-cache"] &&
            curBoxes[i].setAttribute(
              "style",
              curBoxes[i].attributes["swiper-animate-style-cache"].value
            ),
            (curBoxes[i].style.visibility = "hidden"),
            (curBoxes[i].className = curBoxes[i].className.replace(
              "animated",
              " "
            )),
            curBoxes[i].attributes["swiper-animate-effect"] &&
              ((effect = curBoxes[i].attributes["swiper-animate-effect"].value),
              (curBoxes[i].className = curBoxes[i].className.replace(
                effect,
                " "
              )));
        }
      }
    }
  },
};
module.exports = swiperAnimateAction;
